<template>
  <div style="width:100%;height:100%;box-sizing:border-box;overflow-x:hidden;overflow-y:auto;background: #D64445;">
    <el-menu class="el-menu-vertical" :default-active="data.activeIndex" @select="handleSelect"
      :collapse="data.isCollapse">
      <el-menu-item index="forms" style="padding:0 5px 0 2px!important;">
        <el-icon class="icon">
          <Plus />
        </el-icon>
        <template #title>
          <p class="title">{{ $t('title.initiate') }}</p>
        </template>
      </el-menu-item>
      <el-menu-item index="unfinished" style="padding:0 5px 0 2px!important;">
        <el-icon class="icon">
          <Notification />
        </el-icon>
        <template #title>
          <p class="title">{{ $t('title.backlog') }}</p>
        </template>
      </el-menu-item>
      <el-menu-item index="finished" style="padding:0 5px 0 2px!important;">
        <el-icon class="icon">
          <Finished />
        </el-icon>
        <template #title>
          <p class="title">{{ $t('title.haveDone') }}</p>
        </template>
      </el-menu-item>
      <el-menu-item index="submit" style="padding:0 5px 0 2px!important;">
        <el-icon class="icon">
          <Position />
        </el-icon>
        <template #title>
          <p class="title">{{ $t('title.sent') }}</p>
        </template>
      </el-menu-item>
      <el-menu-item index="cc" style="padding:0 5px 0 2px!important;">
        <el-icon class="icon">
          <CopyDocument />
        </el-icon>
        <template #title>
          <p class="title">{{ $t('title.copy') }}</p>
        </template>
      </el-menu-item>
      <el-menu-item index="report" id="report"
        v-if='data.menus.length > 0 || data.roles.includes("WFLOW_APPROVAL_ADMIN")' style="padding:0 5px 0 2px!important;">
        <el-icon class="icon">
          <Management />
        </el-icon>
        <template #title>
          <p class="title">{{ $t('title.reportCenter') }}</p>
        </template>
      </el-menu-item>
      <template v-if='data.roles.includes("WFLOW_APPROVAL_ADMIN")'>
        <el-divider></el-divider>
        <el-menu-item index="instances" style="padding:0 5px 0 2px!important;">
          <el-icon class="icon">
            <PieChart />
          </el-icon>
          <template #title>
            <p class="title">{{ $t('title.management') }}
            </p>
          </template>
        </el-menu-item>
        <el-menu-item index="formsPanel" style="padding:0 5px 0 2px!important;">
          <el-icon class="icon">
            <Tools />
          </el-icon>
          <template #title>
            <p class="title">{{ $t('title.procseeMang') }}
            </p>
          </template>
        </el-menu-item>
        <el-menu-item index="subProcess" style="padding:0 5px 0 2px!important;">
          <el-icon class="icon">
            <Coin />
          </el-icon>
          <template #title>
            <p class="title">{{ $t('title.subprocess') }}
            </p>
          </template>
        </el-menu-item>
        <el-menu-item index="roleManage" style="padding:0 5px 0 2px!important;">
          <el-icon class="icon">
            <FirstAidKit />
          </el-icon>
          <template #title>
            <p class="title">{{ $t('title.roleMang') }}
            </p>
          </template>
        </el-menu-item>
        <el-menu-item index="deptAllocation" style="padding:0 5px 0 2px!important;">
          <el-icon class="icon">
            <Money />
          </el-icon>
          <template #title>
            <p class="title">{{ $t('title.allocation') }}</p>
          </template>
        </el-menu-item>
        <el-menu-item index="dictionaryConfiguration" style="padding:0 5px 0 2px!important;">
          <el-icon class="icon">
            <List />
          </el-icon>
          <template #title>
            <p class="title">{{ $t('title.configuration') }}</p>
          </template>
        </el-menu-item>
        <el-menu-item index="errorInfo" style="padding:0 5px 0 5px 0 2px!important;">
          <el-icon class="icon">
            <List />
          </el-icon>
          <template #title>
            <p class="title">{{ $t('title.interface') }}</p>
          </template>
        </el-menu-item>
      </template>
    </el-menu>
  </div>
</template>

<script setup>
import { reactive, ref, computed, onMounted } from "vue";
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter, useRoute } from "vue-router";
import { useStore } from 'vuex';
import { useI18n } from 'vue-i18n';

const { t } = useI18n();

const route = useRoute();
const router = useRouter();
const store = useStore();

const props = defineProps({
  active: {
    type: String,
    default: ''
  }
})
const data = reactive({
  isCollapse: false,
  activeIndex: 'forms',
  roles: localStorage.getItem('roles') || '', // 角色判断显示权限
  menus: localStorage.getItem('menus') || ''
})

const emits = defineEmits(['getchildren'])

onMounted(() => {
  data.menus=localStorage.getItem('menus')  // 获取菜单权限
  data.roles=localStorage.getItem('roles')  // 角色判断显示权限
  if (data.isMobile) {
    data.isCollapse = true
  }

  if(props.active){
    data.activeIndex=props.active
  }
})
const handleSelect = (e) => {
  // console.log(e)
  emits("getchildren", e)
}



</script>

<style scoped lang="less">
.notify {
  max-height: 200px;
  background: #f7f7f9;
  overflow-y: auto;

  .notify-item:last-child {
    border-bottom: 2px solid #f7f7f9;
  }

  .notify-item {
    border-top: 2px solid #f7f7f9;
    padding: 5px;
    background: white;
    position: relative;
    border-radius: 5px;

    .notify-item-title {
      cursor: pointer;
      color: #3b3b3b;

      &:hover {
        color: white;
      }
    }

    .notify-item-content {
      color: #8c8c8c;
      padding: 5px 0;
      font-size: smaller;
    }

    .notify-item-time {
      position: absolute;
      right: 45px;
      top: 7px;
      font-size: 12px;
      color: #8c8c8c;
    }

    .notify-btn {
      position: absolute;
      right: 5px;
      top: 8px;
    }

    .notify-item-type-icon {
      font-size: 18px;
    }
  }
}

.notify-action {
  display: flex;
  padding-top: 5px;
  justify-content: space-between;
}

.el-menu-vertical:not(.el-menu--collapse) {
  width: auto;
  min-width:65px;
}

.m-aside-menu {
  position: fixed;
  z-index: 999;
  height: 100vh;
}

:deep(.el-menu-item) .icon {
  color: #fff;
}

:deep(.el-menu-item.is-active) .icon {
  color: #fff;
}


.aside-menu {
  background: #D64445;
  width: auto !important;

  :deep(.icon) {
    font-size: large;
    margin-right: 5px;
  }

  .logo {
    height: 80px;
    line-height: 80px;
    display: flex;
    align-items: center;
    margin-left: 10px;

    img {
      width: 45px;
      height: 30px;
      margin-right: 10px;
      padding: 5px;
      border-radius: 12px;
    }

    span {
      font-size: 14px;
      font-weight: bold;
      color: black;
    }
  }

  &::-webkit-scrollbar {
    width: 0;
    height: 0;
  }

  &::-webkit-scrollbar-thumb {
    border-radius: 16px;
  }
}

:deep(.el-menu) {
  margin: 0 0 10px 0;
  background: #D64445;
  overflow: hidden;
  box-sizing: border-box;

  .el-menu-item {
    height: 60px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
  }

  .icon {
    font-size: 40px;
    color: #fff;
  }

  .title {
    height: 30px;
    margin: 0 !important;
    line-height: 10px;
    font-size: 14px;
    color: #fff;
  }

  .el-divider--horizontal {
    margin: 12px 0;
  }

  .el-menu-item.is-active {
    background: #eba2a2;
    color: #fff;
  }
}

:deep(.el-badge) {
  line-height: normal;
}

:deep(.container) {
  background: white;
  height: 100vh;

  .el-header {
    position: relative;
    line-height: 80px;

    .action {
      position: absolute;
      height: 80px;
      line-height: 80px;

      :deep(.icon) {
        cursor: pointer;
        padding: 5px;
      }
    }
  }

  .user-avatar {
    cursor: pointer;
    position: absolute;
    right: 30px;
    height: 60px;
  }

  .message {
    position: absolute;
    right: 170px;
    margin: -10px auto;

    .icon {
      font-size: 18px;
      color: #a2a4a8;
      padding: 1px;
      cursor: pointer;

      &:hover {
        color: #6d6e70;
      }
    }
  }
}

@media screen and (max-width: 800px) {
  :deep(.el-main) {
    padding: 10px;

    .group {
      margin: 0 0 15px 0px !important;
    }
  }
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
  background-color: white;
}

::-webkit-scrollbar-thumb {
  border-radius: 16px;
  background-color: #e8e8e8;
}

.language {
  height: 100%;
  width: 35px;
  margin: 0 3px;
  position: absolute;
  top: 0;
  right: 120px;
  display: flex;
  flex-direction: row;

  .langs {
    height: 15px;
    width: 15px;
    margin: 22px auto;
  }

  span {
    display: inline-block;
    font-size: 13px;
    margin-top: -10px;
  }
}

.language::after {
  content: '';
  width: 2px;
  height: 15px;
  position: absolute;
  left: -6px;
  top: 22px;
  background-color: rgb(0, 123, 255);
}
</style>